import 'package:flutter/material.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/store/view/shopping_bottow_view.dart';
import 'package:flutter_douban/main_page/store/view/shopping_cell.dart';
import 'package:flutter_douban/main_page/store/view/stroe_product_cell.dart';
import 'package:flutter_douban/main_page/store/provider/store_count_model.dart';
import 'package:flutter_douban/tool_views/back_nav_btn.dart';
import 'package:flutter_douban/tool_views/nav_title_page.dart';
import 'package:provider/provider.dart';

class ShoppingCartPage extends StatefulWidget {
  const ShoppingCartPage({Key? key}) : super(key: key);

  @override
  _ShoppingCartPageState createState() => _ShoppingCartPageState();
}

class _ShoppingCartPageState extends State<ShoppingCartPage> {
  ScrollController? _controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        leading: BackNavBtn(),
        title: NavTitlePage(
          titleStr:
              '购物车(${Provider.of<StoreCountModel>(context).count})',
        ),
      ),
      body: Stack(
        children: [
          Container(
            color: AppColors.page,
            padding: EdgeInsets.only(bottom: 45,top: 10),
            child: ListView.builder(
              // shrinkWrap: true,
              controller: _controller,
              itemCount: Provider.of<StoreCountModel>(context).storeList.length,
              itemBuilder: (context, index) {
                return ShopingCell(
                  model: Provider.of<StoreCountModel>(context).storeList[index],
                );
              },
            ),
          ),
          Positioned(
              bottom: MediaQuery.of(context).padding.bottom,
              child: ShoppingBottowView())
        ],
      ),
    );
  }
}
